*use "TESS_cleaned_replication.dta"

*PROTESTANTS AND CHRISTIANS*
preserve
collapse (mean) mean_one=one mean_db=db (sd) sd_one=one sd_db=db (count) n_one=one n_db=db if (prot==1 | christian==1) [aw=WEIGHT]
foreach i in one db{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
}

g test6=5.5 
g test7=6.5

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data2.dta", replace 
restore


preserve
collapse (mean) mean_ba_only=ba_only mean_evan_only=evan_only mean_both=both mean_neither=neither (sd) sd_ba_only= ba_only sd_evan_only= evan_only sd_both= both sd_neither=neither (count) n_ba_only= ba_only n_evan_only= evan_only n_both= both n_neither=neither if (prot==1 | christian==1) [aw=WEIGHT]

foreach i in evan_only both ba_only neither{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
}

g test1=0.5
g test2=1.5
g test3=2.5
g test4=3.5

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data3.dta", replace
restore


clear
use "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data1a.dta"
foreach i in 1b 1c 2 3{
append using "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data`i'.dta"
}

graph twoway   (bar mean_evan_only test1, fcolor(gs8) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hievan_only loevan_only test1, lcolor(black) lpattern(solid) lwidth(medthick)) ///
  (bar mean_both test2, fcolor(gs15) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hiboth loboth test2, lcolor(black) lpattern(solid) lwidth(medthick)) ///
  (bar mean_ba_only test3, fcolor(gs4) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hiba_only loba_only test3, lcolor(black) lpattern(solid) lwidth(medthick)) ///
(bar mean_neither test4, fcolor(gs11) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hineither loneither test4, lcolor(black) lpattern(solid) lwidth(medthick)) ///
(bar mean_one test6, fcolor(none) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hione loone test6, lcolor(black) lpattern(solid) lwidth(medthick)) ///
 (bar mean_db test7, fcolor(black) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hidb lodb test7, lcolor(black) lpattern(solid) lwidth(medthick)), ///
xline(4.5, lcolor(black) lstyle(dot)) ///
title("Identification as evangelical (Evan) and/or born-again (BA)" "(full sample)", size(medium)) ///
plotregion(lpattern(blank)) ytitle("Percent", size(medium)) ///
yscale(range(-7 80)) ylabel(0(20)80, nogrid) scheme(s1mono) xscale(range(0 7)) ///
legend(off) ///
text( -2.5 1  "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'"  "`=ustrunescape("\u23AD")'" , size(10) color(black) orient(rvertical)) ///
text(-5.5 1 "33% identify as Evan", size(small)) ///
text( 35 2  "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'"  "`=ustrunescape("\u23AD")'" , size(10) color(black) orient(vertical)) ///
text(38 2 "52% identify as BA", size(small)) ///
xlabel(0.5 `""Evan" "only""' 1.5 `""Both evan" "and BA""' 2.5 `""BA" "only""' 3.5 `""Neither evan" "nor BA""' 5.5 `""Single" "barreled""' 6.5 `""Double" "barreled""', labsize(small)  tlcolor(none)) ///
text(75 2 "Identification as Evan or BA" "using single-barreled questions", size(small)) ///
text(75 6 "Question wording effects:" "share identifying as Evan or BA", size(small)) 



*WHITE PROTESTANTS AND CHRISTIANS
preserve
collapse (mean) mean_one=one mean_db=db (sd) sd_one=one sd_db=db (count) n_one=one n_db=db if white==1 & (prot==1 | christian==1) [aw=WEIGHT]

foreach i in one db{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
}

g test6=5.5 
g test7=6.5

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data2.dta", replace
restore

preserve
collapse (mean) mean_ba_only=ba_only mean_evan_only=evan_only mean_both=both mean_neither=neither (sd) sd_ba_only= ba_only sd_evan_only= evan_only sd_both= both sd_neither=neither (count) n_ba_only= ba_only n_evan_only= evan_only n_both= both n_neither=neither if white==1 & (prot==1 | christian==1) [aw=WEIGHT]

foreach i in evan_only both ba_only neither{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
}

g test1=0.5
g test2=1.5
g test3=2.5
g test4=3.5

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data3.dta", replace
restore

clear
use "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data1a.dta"
foreach i in 1b 1c 2 3{
append using "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data`i'.dta"
}


graph twoway   (bar mean_evan_only test1, fcolor(gs8) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hievan_only loevan_only test1, lcolor(black) lpattern(solid) lwidth(medthick)) ///
  (bar mean_both test2, fcolor(gs15) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hiboth loboth test2, lcolor(black) lpattern(solid) lwidth(medthick)) ///
  (bar mean_ba_only test3, fcolor(gs4) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hiba_only loba_only test3, lcolor(black) lpattern(solid) lwidth(medthick)) ///
(bar mean_neither test4, fcolor(gs11) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hineither loneither test4, lcolor(black) lpattern(solid) lwidth(medthick)) ///
(bar mean_one test6, fcolor(none) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hione loone test6, lcolor(black) lpattern(solid) lwidth(medthick)) ///
 (bar mean_db test7, fcolor(black) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hidb lodb test7, lcolor(black) lpattern(solid) lwidth(medthick)), ///
xline(4.5, lcolor(black) lstyle(dot)) ///
title("Identification as evangelical (Evan) and/or born-agian (BA)" "(White subsample)", size(medium)) ///
plotregion(lpattern(blank)) ytitle("Percent", size(medium)) ///
yscale(range(-7 80)) ylabel(0(20)80, nogrid) scheme(s1mono) xscale(range(0 7)) ///
legend(off) ///
text( -2.5 1  "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'"  "`=ustrunescape("\u23AD")'" , size(10) color(black) orient(rvertical)) ///
text(-5.5 1 "35% identify as Evan", size(small)) ///
text( 35 2  "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'"  "`=ustrunescape("\u23AD")'" , size(10) color(black) orient(vertical)) ///
text(38 2 "50% identify as BA", size(small)) ///
xlabel(0.5 `""Evan" "only""' 1.5 `""Both evan" "and BA""' 2.5 `""BA" "only""' 3.5 `""Neither evan" "nor BA""' 5.5 `""Single" "barreled""' 6.5 `""Double" "barreled""', labsize(small)  tlcolor(none)) ///
text(75 2 "Identification as Evan or BA" "using single-barreled questions", size(small)) ///
text(75 6 "Question wording effects:" "share identifying as Evan or BA", size(small)) 


*BLACK PROTESTANTS AND CHRISTIANS
preserve
collapse (mean) mean_one=one mean_db=db (sd) sd_one=one sd_db=db (count) n_one=one n_db=db if black==1 & (prot==1 | christian==1) [aw=WEIGHT]

foreach i in one db{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.08)*(sd_`i' / sqrt(n_`i'))
}

g test6=5.5 
g test7=6.5

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data2.dta", replace
restore

preserve
collapse (mean) mean_ba_only=ba_only mean_evan_only=evan_only mean_both=both mean_neither=neither (sd) sd_ba_only= ba_only sd_evan_only= evan_only sd_both= both sd_neither=neither (count) n_ba_only= ba_only n_evan_only= evan_only n_both= both n_neither=neither if black==1 & (prot==1 | christian==1) [aw=WEIGHT]

foreach i in evan_only both ba_only neither{
generate hi`i' = mean_`i' + invttail(n_`i'-1,0.05)*(sd_`i' / sqrt(n_`i'))
generate lo`i' = mean_`i' - invttail(n_`i'-1,0.05)*(sd_`i' / sqrt(n_`i'))
}

g test1=0.5
g test2=1.5
g test3=2.5
g test4=3.5

save "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data3.dta", replace
restore

clear
use "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data1a.dta"
foreach i in 1b 1c 2 3{
append using "~/Dropbox/evangelical identities/Question wording - evangelical versus born again/TESS/Data/Final data/temp/data`i'.dta"
}

graph twoway   (bar mean_evan_only test1, fcolor(gs8) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hievan_only loevan_only test1, lcolor(black) lpattern(solid) lwidth(medthick)) ///
  (bar mean_both test2, fcolor(gs15) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hiboth loboth test2, lcolor(black) lpattern(solid) lwidth(medthick)) ///
  (bar mean_ba_only test3, fcolor(gs4) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hiba_only loba_only test3, lcolor(black) lpattern(solid) lwidth(medthick)) ///
(bar mean_neither test4, fcolor(gs11) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hineither loneither test4, lcolor(black) lpattern(solid) lwidth(medthick)) ///
(bar mean_one test6, fcolor(none) lcolor(black) lpattern(solid) lwidth(medthick)) (rcap hione loone test6, lcolor(black) lpattern(solid) lwidth(medthick)) ///
 (bar mean_db test7, fcolor(black) lcolor(black) lpattern(solid)  lwidth(medthick)) (rcap hidb lodb test7, lcolor(black) lpattern(solid) lwidth(medthick)), ///
xline(4.5, lcolor(black) lstyle(dot)) ///
title("Identification as evangelical (Evan) and/or born-agian (BA)" "(African-American subsample)", size(medium)) ///
plotregion(lpattern(blank)) ytitle("Percent", size(medium)) ///
yscale(range(-7 80)) ylabel(0(20)80, nogrid) scheme(s1mono) xscale(range(0 7)) ///
legend(off) ///
text( -2.5 1  "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'"  "`=ustrunescape("\u23AD")'" , size(10) color(black) orient(rvertical)) ///
text(-5.5 1 "25% identify as Evan", size(small)) ///
text( 44 2  "`=ustrunescape("\u23AB")'" "`=ustrunescape("\u23AC")'"  "`=ustrunescape("\u23AD")'" , size(10) color(black) orient(vertical)) ///
text(48 2 "57% identify as BA", size(small)) ///
xlabel(0.5 `""Evan" "only""' 1.5 `""Both evan" "and BA""' 2.5 `""BA" "only""' 3.5 `""Neither evan" "nor BA""' 5.5 `""Single" "barreled""' 6.5 `""Double" "barreled""', labsize(small)  tlcolor(none)) ///
text(75 2 "Identification as Evan or BA" "using single-barreled questions", size(small)) ///
text(75 6 "Question wording effects:" "share identifying as Evan or BA", size(small)) 


